package com.sky.loveshop.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sky.loveshop.entity.Category;
import com.sky.loveshop.entity.qo.CategoryQO;
import com.sky.loveshop.mapper.CategoryMapper;
import com.sky.loveshop.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xcy
 * @version V1.0
 * @description
 * @date 2024/8/18 0:06
 */
@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> listCategory(CategoryQO categoryQO) {
        return categoryMapper.searchAll(categoryQO);
    }

    @Override
    public PageInfo<Category> listCategoryPages(CategoryQO categoryQO) {
        PageHelper.startPage(categoryQO.getPageNum(), categoryQO.getPageSize());
        List<Category> shops = categoryMapper.searchAll(categoryQO);
        return new PageInfo<>(shops);
    }

    @Override
    public Category getCategoryById(Integer id) {
        return categoryMapper.getCategoryById(id);
    }

    @Override
    public Integer addCategory(Category category) {
        return categoryMapper.insertOne(category);
    }

    @Override
    public Integer delCategoryById(Integer id) {
        return categoryMapper.delCategoryById(id);
    }

    @Override
    public Integer updateCategoryById(Category category) {
        return categoryMapper.updateCategoryById(category);
    }

    @Override
    public List<Category> getCategoryListByIds(List<Integer> ids) {
        return categoryMapper.getCategoryListByIds(ids);
    }

}
